import { getBusinessList, getBusinessInfo, getBusinessNotice } from '../../api/home'

const state = {
  businessList: [],
  businessInfo: {},
  businessNotice: {}
}
const mutations = {
  GETBUSINESSLIST(state, businessList) {
    state.businessList = businessList
  },
  GETBUSINESSINFO(state, businessInfo) {
    state.businessInfo = businessInfo
  },
  GETBUSINESSNOTICE(state, businessNotice) {
    state.businessNotice = businessNotice
  }
}
const actions = {
  async getBusinessList({ commit }) {
    const { data } = await getBusinessList()
    if (data.code == 200) {
      commit('GETBUSINESSLIST', data.data)
    }
  },
  async getBusinessInfo({ commit }, branch_shop_id) {
    const { data } = await getBusinessInfo(branch_shop_id)
    if (data.code == 200) {
      commit('GETBUSINESSINFO', data.data)
    }
  },
  async getBusinessNotice({ commit }, branch_shop_id) {
    const { data } = await getBusinessNotice(branch_shop_id)
    if (data.code == 200) {
      commit('GETBUSINESSNOTICE', data.data)
    }
  }
}
const getters = {}

export default {
  state,
  mutations,
  actions,
  getters
}
